package com.example.chapter3_5.mapper;


import com.example.chapter3_5.entity.Blog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BlogMapper {
    //查找数据库里面所有的博客数据
    @Select("select * from m_blog")
    List<Blog> selectAll();
    //查询分页数据,跳过前 offset行，返回接下来的 limit 行数据
    @Select("select * from m_blog order by created_at desc limit #{limit} offset #{offset}")
    List<Blog> findBlogsByPage(int offset, int limit);
    //查询博客总数量
    @Select("select count(*) from m_blog")
    int countBlogs();

}
